|
|
|
|
|
|
|
If (style& And WS_BORDER)=0 Then
' This code will execute if the window does not have a border
End If |
|
|
|
|
|
|
|
|
Now that you understand how Visual Basic uses Boolean operators, it's time to take a quick look at how the C language differs from VB. Visual Basic Boolean variables are identical to integer variables. And because Visual Basic Boolean operators act on each bit in a variable, you must set variables to 1 for True and 0 for False in order for comparisons to work correctly. |
|
|
|
|
|
|
|
|
The C language takes a radically different approach. It defines two distinct sets of Boolean operators. The first set is designed for comparisons; they base their operation on the value of the entire variable, where a 0 value indicates False and any non-zero value indicates True. These operators are as follows: |
|
|
|
|
| C OPERATOR | MEANING | | && | Logical AND | | || | Logical OR | | ! | Logical NOT |
|
|
|
|
|
|
For example: consider the results of the ! operator on 0, 1, and 1: |
|
|
|
|
|
|
|
|
!0 = Any value other than 0
!1=0
!-1=0 |
|
|
|
|
|
|
|
|
These operators do not work on each bit in the variable, but on the variable as a whole. The Win32 API was initially designed to be used from the C language, so it was perfectly reasonable for the designers of the Win32 API to return any non-zero value to indicate a True result. They knew that programmers would be using the C Logical Boolean comparisons, which would always work correctly with any value. |
|
|
|
|
|
|
|
|
But what do C programmers do when they need to work with individual bitscombining values using the OR operation or masking them using the AND operation? The C language provides a different set of operators for these "bitwise" Boolean operations: |
|
|
|
|
|